<?php
$selected_cat = set_value('dang_dich_vu');
$selected_cat_setting = array(
    'table_name' => 'dang_dichvu',
    'key_field' => 'id',
    'value_field' => 'ten_dich_vu'
);

$user_id = $this->session->userdata('admin_id');

//set month
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");

//get year
$this_day = now();
$pattern = "%Y";
$pattern_date = "%Y-%m-%d";
$str_year = mdate($pattern, $this_day);
$str_date = mdate($pattern_date, $this_day);
for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year + 10; $i > $str_year - 80; $i--) {
    $year_data[$i] = $i;
}
?>

<?php echo form_open('thanh_toan/cap_nhat_thanh_toan/' . $data->id, array('id' => 'register')); ?>
<div id="content">
    <?php if ($this->session->flashdata('warning')): ?>
        <div class="affiche_erreur">
            <?php echo $this->session->flashdata('warning'); ?>
        </div>
    <?php endif; ?>
    <div id="title_content">Cập nhật thanh toán</div>
    <?php echo form_open_multipart('thanh_toan/cap_nhat_thanh_toan/' . $data->id); ?>
    <table class="form_content" width="100%">
        <tr>
           
                <?php
                $active = array(
                    'name' => 'tinh_trang_tra_tien',
                    'id' => 'tinh_trang_tra_tien',
                    'value' => 1,
                    'checked' => $data->tinh_trang_tra_tien == 1 ? TRUE : FALSE,
                    'style' => 'margin:10px',
                );
                echo '<td>Đã thanh toán</td>' .'<td>'. form_checkbox($active).'</td>';
                ?>
            
        </tr>
        <tr>
            <td>Số tiền </td>
            <td>
                <?php if (form_error('so_tien') != "") {
                    ?> <div class="form_error"><?php echo generate_pure_text(form_error('so_tien'), '<p>', '</p>'); ?></div> <?php } ?>
                <input type="text" class="form_input" name="so_tien" size="35" maxlength="40" value="<?php echo set_value('so_tien', $data->so_tien); ?>" /></td>
        </tr>

        <tr>
            <td>Ngày trả tiền</td>
            <td>
                D : <?php echo form_dropdown('pay_date', $day_data, get_date_part($str_date, 'day'), 'id="day" class="short"'); ?>
                M : <?php echo form_dropdown('pay_month', $dropdown_data, get_date_part($str_date, 'month'), 'id="month" class="short"'); ?>
                Y : <?php echo form_dropdown('pay_year', $year_data, get_date_part($str_date, 'year'), 'id="year" class="short"'); ?>
            </td>
        </tr>

        <tr>
            <td>Chi tiết </td>
            <td>
                <?php if (form_error('chi_tiet') != "") {
                    ?> <div class="form_error"><?php echo generate_pure_text(form_error('chi_tiet'), '<p>', '</p>'); ?></div> <?php } ?>

                <textarea name="chi_tiet" cols="80" rows="10"><?php echo set_value('chi_tiet', $data->chi_tiet); ?></textarea>
            </td>
        </tr>

        <tr>
            <td colspan="2"><input type="submit" name="submit" value="Cập nhật" class="form_submit" /></td>
        </tr>
    </table>
    <?php echo form_close(); ?>
</div>